package jfuzzyprincepless.negotiation;

import java.util.List;

import jfuzzyprincepless.agents.INegotiatingAgent;
import jfuzzyprincepless.negotiation.services.IService;
import jfuzzyprincepless.negotiation.services.impl.AgentsListService;
import jfuzzyprincepless.negotiation.services.impl.ServiceRegistry;

public class DefaultNegotiationContext
	implements INegotiationContext, IExecutionContext
{
	private ServiceRegistry serviceRegistry = new ServiceRegistry();

	public DefaultNegotiationContext() {
	}
	
	public DefaultNegotiationContext(
		List<INegotiatingAgent> agentsList
	) {
		registerService(new AgentsListService(agentsList));
	}

	@Override
	public <ServT extends IService> ServT getService(
		Class<ServT> clazz
	) {
		return serviceRegistry.getService(clazz);
	}

	@Override
	public void registerService(IService service) {
		serviceRegistry.registerService(service);
	}
	
	public <ServT extends IService> void registerService(
		Class<ServT> clazz,
		ServT service
	) {
		serviceRegistry.registerService(clazz, service);
	}

	@Override
	public String toString() {
		return "DfNgCnt: " + serviceRegistry.toString();
	}
}
